<script setup lang="ts">
const props = defineProps({
  str: {
    required: true,
    type: String,
    default: "默认"
  }
})
const emit = defineEmits(["test"]);

const childTest = () => {
  emit("test", "我是子组件，调用父组件的方法并传值");
}

/**
 * @description 暴露变量及方法
 */
defineExpose({
});
</script>

<template>
  <div class="child-container">
    <div>Child</div>
    <div>str：{{ props.str }}</div>
    <el-button @click="childTest">调用父组件的方法并传值</el-button>
  </div>
</template>

<style lang="scss" scoped></style>